#ifndef TRANSFORMS_H
#define TRANSFORMS_H

#include "gd32f30x.h"

typedef struct {  int32_t  As;  		// Input: phase-a stator variable
				  int32_t  Bs;			// Input: phase-b stator variable
				  int32_t  Cs;			// Input: phase-c stator variable  
				  int32_t  Alpha;		// Output: stationary d-axis stator variable 
				  int32_t  Beta;		// Output: stationary q-axis stator variable
		 	 	} CLARKE;	            

/*-----------------------------------------------------------------------------
	Default initalizer for the CLARKE object.
-----------------------------------------------------------------------------*/                     
#define CLARKE_DEFAULTS { 0, \
                          0, \
                          0, \
                          0, \
                          0, \
              			} 

/*------------------------------------------------------------------------------
	CLARKE Transformation Macro Definition
------------------------------------------------------------------------------*/

//  1/sqrt(3) = 0.57735026918963
#define  ONEbySQRT3   18978    /* _iq15(1/sqrt(3)) */

typedef struct {  int32_t  Alpha;  		// Input: stationary d-axis stator variable 
				  int32_t  Beta;	 	// Input: stationary q-axis stator variable 
				  int32_t  Angle;		// Input: rotating angle (pu) 
				  int32_t  Ds;			// Output: rotating d-axis stator variable 
				  int32_t  Qs;			// Output: rotating q-axis stator variable
				  int32_t  Sine;
				  int32_t  Cosine; 	 
		 	 	} PARK;	            

/*-----------------------------------------------------------------------------
Default initalizer for the PARK object.
-----------------------------------------------------------------------------*/                     
#define PARK_DEFAULTS {   0, \
                          0, \
                          0, \
                          0, \
                          0, \
						  0, \
                          0, \
              			  }


typedef struct {  int32_t  Alpha;  		// Output: stationary d-axis stator variable
				  int32_t  Beta;		// Output: stationary q-axis stator variable
				  int32_t  Angle;		// Input: rotating angle (pu)
				  int32_t  Ds;			// Input: rotating d-axis stator variable
				  int32_t  Qs;			// Input: rotating q-axis stator variable
				  int32_t  Sine;		// Input: Sine term
				  int32_t  Cosine;		// Input: Cosine term
		 	    } IPARK;	            

/*-----------------------------------------------------------------------------
Default initalizer for the IPARK object.
-----------------------------------------------------------------------------*/                     
#define IPARK_DEFAULTS {  0, \
                          0, \
                          0, \
                          0, \
                          0, \
						  0, \
                          0, \
              		   }
					   
					   
void CLARKE_Run(CLARKE *v);
void PARK_Run(PARK *v);
void iPARK_Run(IPARK *v);

#endif
